<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    padding: 3px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .weui-label {
    text-align: left;
  }
</style>
<template>
  <div class="oitem">
<!--    <div class="weui-cells__title">货品明细 {{itemNo + 1}}</div>-->
<!--    <div class="weui-cell">-->
<!--      <div class="weui-cell__hd"><label class="weui-label">类型</label></div>-->
<!--      <div class="weui-cell__bd">-->
<!--        <input class="weui-input" type="text" name="" readonly="true" :value="product.typeName">-->
<!--      </div>-->
<!--    </div>-->
    <div class="weui-cell fir">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.productName">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.specName">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">数量</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input inlinput1 weight" type="number" placeholder="请输入数量" v-model="weight"  @change="doEmitter">
        <input class="weui-input inlinput2" readonly type="text" :value="product.stockunit">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label for="" class="weui-label">库间</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select houseroom" v-model="shrguid" >
          <option value="0">请选择库间</option>
          <option v-for="(hou, i) in houses" :value="hou.guid">{{hou.name}}</option>
        </select>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'FeedStoreRmItem',
    data () {
      return {
        houses: [],
        shrguid: '',
        weight: ''
      }
    },
    props: [
      'itemNo',
      'product',
      'orgid',
      'strmid',
    ],
    computed: {
    },
    watch: {
      'item.type': function (val) {
        this.getHouses(val);
      },
      'shrguid': function (val) {
        this.doEmitter();
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.getHouses(this.product.type);
      })
    },
    methods: {
      doEmitter(){
        this.model = {
          guid: this.product.guid,
          productid: this.product.productid,
          specguid: this.product.specguid,
          stockunit: this.product.stockunit,
          stockunitid: this.product.stockunitid,
          weight: this.weight,
          shrguid: this.shrguid,
        };
        this.model.index = this.itemNo;
        this.$emit('changeData', this.model);
      },
      getHouses: function(type) {
        if (!this.checkNull(this.strmid)) return;
        this.axios({
          method: 'get',
          url: '/prod-api/getStoreHouseRoomByRoomId',
          params: {id: this.strmid, type: type}
        }).then(response => {
          if (response.data.code == 200) {
            this.houses = response.data.data;
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
        });
      },
    }
  }
</script>
